package app.agent.activity

import im.mange.jetboot.{R, Composite, Renderable}
import app.server._
import app.agent.test.TestAgent
import app.comet.Subscriber
import app.agent.systems.AddSystemAgent
import app.server.TestContent
import app.server.UpdateTestRun
import app.agent.test.TestAgent
import app.agent.systems.AddSystemAgent
import app.server.StartedTestRun
import app.server.StoppedTestRun

case class ActivityAgent(subscriber: Subscriber) extends Renderable {
  private val testAgent = TestAgent(subscriber)
  private val addSystemAgent = AddSystemAgent()

  def render = Composite(testAgent, addSystemAgent).render

  def onTestContent(response: TestContent) = testAgent.onTestContent(response) & addSystemAgent.hide
  def onValidatedTestRun(response: ValidatedTestRun) = testAgent.onValidatedTestRun(response)
  def onStartedTestRun(response: StartedTestRun) = testAgent.onStartedTestRun(response)
  def onStoppedTestRun(response: StoppedTestRun) = testAgent.onStoppedTestRun(response)
  def onUpdateTestRun(response: UpdateTestRun) = testAgent.onUpdateTestRun(response)

  def onAddSystem = addSystemAgent.show & testAgent.hide
}
